package com.myFwk.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myFwk.domain.SysMenu;
import com.myFwk.mapper.SysMenuMapper;
import com.myFwk.service.SysMenuService;
import com.myFwk.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @author GL
 * @version 1.0
 * @date 2021/9/1 23:03
 */
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {


    @Autowired
    private SysRoleService sysRoleService;

    @Autowired
    private SysMenuService sysMenuService;

    @Override
    public List<SysMenu> getMenusByUserId(Long userId) {
        //如果是超级管理员拥有所有的菜单权限
        if (sysRoleService.isSuperAdmin(userId)) {
            //查询素所有的菜单权限
            return list();
        }
        //如果不是超级管理员--通过查询该用户角色--然后查询权限
        return sysMenuService.getMenusByUserId(userId);
    }

    @Override
    public boolean saveBatch(Collection<SysMenu> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<SysMenu> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<SysMenu> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(SysMenu entity) {
        return false;
    }

    @Override
    public SysMenu getOne(Wrapper<SysMenu> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<SysMenu> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<SysMenu> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }


}
